package com.heyqing.topic.GuessNumber_0374;

/**
 * ClassName:GuessNumber
 * Package:com.heyqing.topic.GuessNumber_0374
 * Description:
 *
 * @Date:2024/9/27
 * @Author:Heyqing
 */
public class GuessNumber {
    public int guessNumber(int n) {
        int s = 1, e = n;
        while (s <= n) {
            int m = s + (e - s) / 2;
            if (s == n) return s;
            int guess = guess(m);
            if (guess == 0) return m;
            else if (guess == -1) e = Math.min(m, e - 1);
            else s = Math.max(m, s + 1);
        }
        return s;
    }

    private int guess(int n) {
        return 0;
    }
}
